/**
Author: Lei Zhang
File Creation Date: Apr 8, 2014
Class Description:
*/
package bestroomie.gui;

import javax.swing.*;

import bestroomie.controller.BRAbstractController;
import bestroomie.util.BRUtil;

import java.awt.*;


/***
 * 
 * This is where the settings guy should work on
 * **/
//public class BRHeadPanel extends BRMainPanel {
//	
//	private JLabel welcomeLbl;
//	private JLabel grpStatsLbl;
//	private JButton settingsBtn;
//	
//	
//	public void setGrpStatsLbl(int memNum, String gName) {
//		String tmpStr = "There are " +  memNum + " Members in Group " +  gName + ". ";
//		this.grpStatsLbl.setText(tmpStr);
//	}
//	
//	public void setWelcomeLbl(String uName) {
//		String tmpStr = "Welcome customer " + uName + ". ";
//		this.welcomeLbl.setText(tmpStr);
//	}
//	
//	public BRHeadPanel () {
//		this.setPreferredSize(new Dimension(this.headPanelWidth,this.headPanelHeight));
//		
//		welcomeLbl = new JLabel("");
//		//this.setWelcomeLbl(userName);
//		
//		grpStatsLbl = new JLabel("");
//		//this.setGrpStatsLbl(grpMemNum, grpName);
//		
//		settingsBtn = new JButton("Settings");
//		this.add(welcomeLbl,BorderLayout.WEST);
//		this.add(grpStatsLbl,BorderLayout.CENTER);
//		this.add(settingsBtn,BorderLayout.EAST);
//	}
//	
//	public static void main(String args[]) {
//		BRHeadPanel panel = new BRHeadPanel();
//		JFrame frame = new JFrame();
//		frame.add(panel);
//		frame.pack();
//		frame.setVisible(true);
//		frame.setLocationRelativeTo(null);
//	}
//
//	@Override
//	public void registerListener(BRAbstractController a) {
//		// TODO Auto-generated method stub
//		settingsBtn.addActionListener(a);
//	}
//}


public class BRHeadPanel extends BRMainPanel {

    private BRSettings brSettings;

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton("Settings");
        jLabel1 = new javax.swing.JLabel();

        jButton1.setText("Settings");
        jButton1.setActionCommand("Settings");

        jLabel1.setText("jLabel1");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 199, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(34, 34, 34))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(40, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addGap(47, 47, 47))
        );
        brSettings = new BRSettings();
    }// </editor-fold>                        

    
    
    public BRHeadPanel () {
//		this.setPreferredSize(new Dimension(this.headPanelWidth,this.headPanelHeight));
//		
//		jLabel1 = new JLabel("testtestsett");
//		jButton1 = new JButton("Settings");
    	
    	initComponents();
		//this.setWelcomeLbl(userName);
		
//		grpStatsLbl = new JLabel("");
		//this.setGrpStatsLbl(grpMemNum, grpName);
		
//		settingsBtn = new JButton("Settings");
//		this.add(welcomeLbl,BorderLayout.WEST);
//		this.add(grpStatsLbl,BorderLayout.CENTER);
//		this.add(settingsBtn,BorderLayout.EAST);
		
	}
    

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration   
    @Override
	public void registerListener(BRAbstractController a) {
		// TODO Auto-generated method stub
    	jButton1.addActionListener(a);
	}
    
    public void setText(String userId, String grpId, int num) {
    	
    	String labelText = "Best Roomie User " + BRUtil.fixedLenthString(userId, 5) + ", with " 
    				       +  BRUtil.fixedLengthInt(num) + " members in " + BRUtil.fixedLenthString(grpId, 2);
    	
    	Font labelFont = jLabel1.getFont();
    	int newFontSize = 14;
    	 
    	this.jLabel1.setText(labelText);
    	this.jLabel1.setFont(new Font(labelFont.getName(),Font.BOLD, newFontSize));
    	
    }
    
    
    public static void main(String args[]) {
//		BRHeadPanel panel = new BRHeadPanel();
//		JFrame frame = new JFrame();
//		frame.add(panel);
//		frame.pack();
//		frame.setVisible(true);
//		frame.setLocationRelativeTo(null);
    	
//    	String s = String.format("BestRoomie user ", );
//    	System.out.println(BRHeadPanel.fixedLenthString("asdf",10));
	}
    
    public BRSettings getBrSettings() {
		return brSettings;
	}

	public void setBrSettings(BRSettings brSettings) {
		this.brSettings = brSettings;
	}
}

